
import axios from 'axios';
import qs from 'qs';
Vue.prototype.$qs = qs;
import ServerConfig from '../../public/serverConfig.json';
import Vue from 'vue';
//批量
export const  videosUploads = (token,domain,address,file,self) =>{

    return new Promise((resolve, reject) => {
      //  console.log(self.progress);return false;
        var timenow= Date.parse(new Date())
        var key = address+ localStorage.getItem("uid")+"_"+timenow+"_"+file.name;
        var qiniu = require('qiniu-js')
        var config = {
            region: qiniu.region.cnEast2,
            uptoken: token,
            domain:domain,     //配置好的七牛云域名  如   https://cdn.qniyun.com/
            unique_names: false,
            chunkSize: 100,   // 分片设置
            forceDirect: true  // 断点上传
         };
        var putExtra = {
            fname: "",
            params: {},
            mimeType: [] || null
        };
        var observer = {
            next(res){
                self.filePercent= parseInt(res.total.percent)
            },
            error(err){
            },
            complete(res){
              //  self.cropImg2 =  self.form.route;
                self.progress = false;
            }
        }
        var observable = qiniu.upload(file, key , token , putExtra, config)
        var subscription = observable.subscribe(observer) // 上传开始
        resolve(key)
    })


}

    function filePercent(num){
        console.log(num);
    }






